Skip to content

server: a refused handover's 409 comes from a typed failure code, not the message text (#2349, after #5729) - #6239

Merged
ashhart merged 4 commits into
ashhart:mainfrom
ThinkOffApp:pr/5729-followup-20261203
Dec 5, 2026
Merged

ashhart merged 4 commits into
ashhart:mainfrom
ThinkOffApp:pr/5729-followup-20261203

Conversation

@ThinkOffApp

Copy link
Copy Markdown
Contributor

What this changes

Three review fixes held back from #5729, which is now merged. One behaviour changes:

  • Before: the server answered 409 handover_not_loaded for any failed reply whose message starts with handover_not_loaded. A completion with no handover got that 409 if its engine's failure text started the same way.
  • After: when the lane host refuses a handover it sets failure_code = .handover_not_loaded on the failed finished event, and the server maps the 409 from that code. The message text is unchanged and no longer decides the status.

Commits:

  1. 0f62b9378, test only: --handover and --learn-daily-gib 2.5 parse the same in either order (handover_cli_test.zig).
  2. 0acc63819, test only: a populated scoped store shares the prompt-cache budget and sheds under a memory-pressure warning (lane_host_pressure_test.zig).
  3. b93b3e32d, the fix: FailureCode in engine_api.zig. lane_host.zig sets it in finish and gains dropHandover, which the three refusals in lane_stream.zig call. mailbox.zig carries it. chat_generation.zig reads it in place of std.mem.startsWith. It adds one test (completion_prompt_test.zig), re-pins lane_host.zig in zig/tests/fixtures/gradient-serving.tsv (the row's note cites Team Drift step 1: hand a kept prompt state to another session of the same model (#2349) #5729, because this pull request had no number yet) and registers the step test-handover-review-host.

Commits 1 and 2 add tests for behaviour main already has and change no source file. They were run on this head only. Commit 3's test is the one that fails before the change.

Checks on this head

  • Head commit: b93b3e32d, on main 1f437b986.
  • Lean checker, on the base and on this head, run through python3 tools/pr_check.py --base upstream/main: 88 and 88, 0 new. 0 errors, 3 advisory warnings: two inherited import cycles, and the Unreleased line, which it cannot check without a pull request number.
  • Tests run, with the command and pass, fail and skip counts, on macOS arm64 with Zig 0.17.0:
    • zig build -j2 -Dfixed-cpu test-gradient-serving test-qwen-serving-host test-glm-pdl-scan --summary all: 13/13 steps, 9/9 tests pass.
    • zig build -j2 test-lane-api-host test-memory-pressure-host test-lane-strand-host test-lane-explore-host test-lane-halt-host test-lane-interrupted-host test-lane-lone-host --test-timeout 30m --summary all: 24/24 steps, 1134/1134 pass.
    • zig build -j2 test-prompt-cache-host --test-timeout 30m --summary all: 5/5 steps, 866/866 pass.
    • zig build -j2 test-handover-review-host test-serve-flags-host test-memory-pressure-status-host test-qwen27-prefill-stats-host --test-timeout 30m --summary all: 14/14 steps, 146/148 pass, 2 skipped, 0 failed.
    • zig build -j2 test-server-cpu --test-timeout 30m --summary all: 12/12 steps, 2314/2339 pass, 25 skipped, 0 failed.
    • zig fmt --check build.zig zig: exit 0. git diff --check upstream/main..HEAD: exit 0.
  • Fail before, pass after: on main 1f437b986 with only commit 3's change to completion_prompt_test.zig applied, zig build -j2 test-server-cpu --test-timeout 30m --summary all fails in that one test, "handover-like engine text never changes an ordinary completion failure status", with expected 500, found 409 (10/12 steps, 2312/2338 pass, 25 skipped, 1 failed). On this head the same step passes. The tests of commits 1 and 2 were run on this head only.
  • CI: no run on this head yet.
  • Not run, and why:
    • Full zig build test and test-golden: not run for this follow-up. The steps above are the lane host module's whole suite, the server module's whole suite and the serving pin check.
    • The test-host aggregate: it is Linux only, and these runs were on macOS.
    • Linux, Windows and any GPU or device run (Metal, CUDA, HIP): not run. See the receipt.

Receipt

No token, prompt or cache path changes. The one runtime change is the extra field on the failed finished event and the 409 mapped from it.

  • Main against branch: cells and numbers, or why they can't be run: not run. No GPU or checkpoint run was made for this follow-up. The host tests above are the only evidence.
  • Boxes it reaches: every backend that serves through the lane host, on the failure path only. No backend or kernel file changes.
  • New switch? Default, accepted values, profile row: none.
  • Environment, with the TensorFold commit, Zig and backend toolchain, machine and GPU, checkpoint and revision: head b93b3e32d on main 1f437b986, Zig 0.17.0, macOS 27 on an Apple M5 Max, host tests only. No backend toolchain, GPU or checkpoint was used.
  • Paths and platforms the change reaches, which I ran and which I could not: it reaches the handover refusals in lane_stream.zig, the finished event, the server mailbox and the failed branch of the reply's finish in chat_generation.zig. Ran: host tests on macOS arm64. Not run: Linux, Windows, and any Metal, CUDA or HIP device.
  • Exactness, from tools/bench_concurrent.py --alone --serial or token_sha against "draft": false: n/a, not run. This diff produces and changes no token.
  • Main against this branch, same machine and checkpoint, posted before asking for a run on our machines (or why you can't): n/a. No checkpoint run was made, and no run on your machines is asked for.
  • Decode speed before and after, from tools/bench_openai.py: n/a, not measured. No decode code changes.
  • Speed claims: n/a. This makes no speed claim, so there is no performance receipt.
  • Prompt speed before and after: n/a. The change cannot reach prompt processing: in lane_stream.zig it only swaps drop for dropHandover on three refusal returns, taken before any lookup or prefill.
  • Licence of any new weights or drafter, or "n/a": n/a. No weights or drafter.

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency. Commit 3's test does: expected 500, found 409 on main, and it passes here. The tests of commits 1 and 2 cover existing behaviour, so they are not expected to fail before; they were run on this head only. None has an outside dependency to skip on.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.
  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off. No token path changes.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. Not measured. No token, prompt or cache path changes.
  • No precision traded for speed. If the bits change, the description says which sums change and why. No arithmetic changes.
  • A speedup PR includes a tools/perf_receipt.py receipt that passes verify. n/a: not a speedup.
  • Decode and prompt processing are no slower than main at one stream and the widest admitted; with --drafter, no slower than without it, greedy and sampled. Not measured. No decode or prompt code changes.

@ashhart ashhart added kind:bug Classified by Synthena as bug fix synthena:needs-device Initial diff review passed; waiting for device and slowdown check before READY labels Dec 3, 2026
@ashhart

ashhart commented Dec 3, 2026

Copy link
Copy Markdown
Owner

Synthena Initial Review — Initial diff check passed (awaiting device run) (kind:bug)

Replaces the message-text prefix match that mapped a failed reply to a 409 handover_not_loaded with a typed FailureCode set by the lane host on handover refusals, plus two test-only commits covering CLI flag-order parsing and scoped-store pressure sharing.

  • Touches runtime, kernel, or serving paths; awaiting device and performance verification before landing.

Findings:

  • [NIT] zig/src/core/lane_host.zig: The code is set only when reason == .failed, but dropHandover is also reachable via paths that may finish with a different reason; if any refusal path finishes non-failed the code is silently dropped. Suggested fix: Confirm all three refusal call sites finish with reason .failed; if so this is fine, otherwise set the code independent of reason.
  • Synthena

@ThinkOffApp

Copy link
Copy Markdown
Contributor Author

On the nit about failure_code in lane_host.zig: checked, and no change is needed.

  • dropHandover (lane_host.zig:514) has three call sites, all in lane_stream.zig (23, 25, 29). It sets the flag and returns h.drop, and drop always ends in h.finish(job, .failed, message) (lane_host.zig:522). None of the three can finish with another reason.
  • The flag has one other setter, refusesHandover (lane_job.zig:80, already on main), for a state that fails to restore. On a normal return its callers drop the job at once (lane_host.zig:438, lane_host_fill.zig:229), so it fails with the code. handover_http_test.zig:365 covers that path end to end: 409 and handover_not_loaded.
  • A flagged job can finish with another reason in one case: the restore fails and the request is cancelled in the same pass (error.Cancelled from lanes/open_first.zig:51 or 56, then cancel at lane_host.zig:527). It finishes .cancelled with no code, which is what the reason == .failed guard is for: a cancelled request does not report a handover failure. If a halt is draining at that moment, cancel finishes it .failed with the halt's reason and the code, so it answers 409 handover_not_loaded with the halt's text. Its scope is already marked lost by then, so later requests in the scope answer the same code.

@ashhart

ashhart commented Dec 5, 2026

Copy link
Copy Markdown
Owner

READY to land on this head. Re-checked this head after your reply: all three refusal sites finish as failed, the halt case answers 409 with the halt's text, and the new test fails on main (500) and passes here. Nothing more is needed from you; the landing train's checks run before it lands.

  • Synthena

@ashhart ashhart removed the synthena:needs-device Initial diff review passed; waiting for device and slowdown check before READY label Dec 5, 2026
@ashhart
ashhart force-pushed the pr/5729-followup-20261203 branch from b93b3e3 to 517216b Compare December 5, 2026 03:42
@ashhart
ashhart merged commit 133d92c into ashhart:main Dec 5, 2026
25 of 39 checks passed
@ashhart

ashhart commented Dec 5, 2026

Copy link
Copy Markdown
Owner

Thank you @ThinkOffApp. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:bug Classified by Synthena as bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants